// 打印所有路由的函数
function printRoutes(app) {
  if (!app || !app._router || !app._router.stack) {
    console.log('No routes found.');
    return;
  }

  const stack = app._router.stack;

  console.log('Routes:');
  stack.forEach((middleware, index) => {
    if (middleware.route) {
      // 路由层
      const route = middleware.route;
      console.log(
        `${index + 1}: ${route.stack[0].method.toUpperCase()} ${route.path}`
      );
    } else if (middleware.name === 'router') {
      // 子路由层
      middleware.handle.stack.forEach((subMiddleware, subIndex) => {
        if (subMiddleware.route) {
          const subRoute = subMiddleware.route;
          console.log(
            `${index + 1}.${subIndex + 1}: ${subRoute.stack[0].method.toUpperCase()} ${
              subRoute.path
            }`
          );
        }
      });
    }
  });
}


export default (opt) => {
    const {
      router,
      modules: {
        'plus-wechat': { controller },
      },
      app,
    } = opt;
 
  router.get("/login", controller.wechat.login);
  printRoutes(app);
  //配置前缀
  app.use('/plus/wechat',router)

};

